package student.utils;

import student.Main;
import student.dto.BookDto;
import student.dto.StudentDto;
import student.dto.TeacherDto;

import java.util.ArrayList;
import java.util.List;

/**
 * @author yangdiankang@51tiangou.com
 * @date 2020/5/9.
 */
public class Utils {

    public static List<StudentDto> buildStuDtos (List<String> strings) {
        Main.studentDtos = new ArrayList<>();
        for (int i = 1; i < strings.size(); i++) {
            String[] s = strings.get(i).trim().split(",");
            StudentDto studentDto = new StudentDto(Integer.valueOf(s[0]), s[1],Integer.valueOf(s[2]),s[3],Integer.valueOf(s[4]));
            Main.studentDtos.add(studentDto);
        }

        return Main.studentDtos;
    }

    public static List<TeacherDto> buildTeaDtos (List<String> strings) {
        Main.teacherDtos = new ArrayList<>();
        for (int i = 1; i < strings.size(); i++) {
            String[] s = strings.get(i).trim().split(",");
            TeacherDto teacherDto = new TeacherDto(Integer.valueOf(s[0]), s[1], Integer.valueOf(s[2]),s[3]);
            Main.teacherDtos.add(teacherDto);
        }

        return Main.teacherDtos;
    }

    public static List<BookDto> buildBookDtos (List<String> strings) {
        Main.bookDtos = new ArrayList<>();
        for (int i = 1; i < strings.size(); i++) {
            String[] s = strings.get(i).trim().split(",");
            BookDto bookDto = new BookDto(Integer.valueOf(s[0]), s[1], s[2],Integer.valueOf(s[3]));
            Main.bookDtos.add(bookDto);
        }

        return Main.bookDtos;
    }


    public static String getNameByType (Integer type) {
        switch (type) {
            case 1:
                return "学生";
            case 2:
                return "老师";
            case 3:
                return "书籍";
        }

        return "";
    }
}
